package xyz.yeidi.service.impl;

import xyz.yeidi.dao.api.BusinessDao;
import xyz.yeidi.dao.impl.BusinessDaoImpl;
import xyz.yeidi.pojo.Business;
import xyz.yeidi.service.api.BusinessService;
import xyz.yeidi.utils.ConnUtils;

import java.util.List;

/**
 * @Author JIP
 * @Date 2021-08-02 19:52
 * @Version 1.0
 * @Describe :
 */
public class BusinessServiceImpl implements BusinessService {
    private BusinessDao businessDao = new BusinessDaoImpl();
    @Override
    public List<Business> getAllBusiness(){
        List<Business> list = null;
        try {
            list = businessDao.getAllBusiness();
        } catch (Exception e) {
            e.printStackTrace();
        }finally {
            ConnUtils.close();
        }
        return list;
    }

    @Override
    public Business getbusinessByid(Integer id) {
        Business business = null;
        try {
            business = businessDao.getBusinessByid(id);
        } catch (Exception e) {
            e.printStackTrace();
        }finally {
            ConnUtils.close();
        }
        return business;
    }

    @Override
    public List<Business> getBusinessByTypeId(Integer typeId) {
        List<Business> list = null;
        try {
            list = businessDao.getBusinessByTypeId(typeId);
        } catch (Exception e) {
            e.printStackTrace();
        }finally {
            ConnUtils.close();
        }
        return list;
    }

    @Override
    public List<Business> searchBusinessByName(String businessName){
        List<Business> list = null;
        try {
            list = businessDao.searchBusinessByName(businessName);
        } catch (Exception e) {
            e.printStackTrace();
        }finally {
            ConnUtils.close();
        }
        return list;
    }


}
